<template>
	<view class="container">
		<u-loading-page :loading="isLoading" loading-text="加载中..."></u-loading-page>
		<view v-if="!isLoading">
			<no-msg-box v-if="!shareList || !shareList.length"></no-msg-box>
			<view v-else>
				<view :class="item.isDelete?'shareItemBox deleteItem':'shareItemBox'" v-for="(item,index) in shareList" :key="index" @click="jumpPage(item)">
					<view class="deleteTxt" v-if="item.isDelete">
						已下架
					</view>
					<view class="topBox">
						<view>
							<text class="titleBox">{{item.businessName}}</text>
							<text class="productNameBox">{{item.businessTypeName}}</text>
						</view>
						<text>分享时间：{{item.gmtCreate}}</text>
					</view>
					<view class="msgBox">
						<view>
							<text>{{item.accessTimes}}</text>
							<view>访问次数</view>
						</view>
						<view>
							<text>{{item.visitorsNums}}</text>
							<view>访问人数</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	import {
		queryMyShareList
	} from "@/apis/product.js"
	import noMsgBox from "@/components/noMsgBox.vue"

	export default {
		components: {
			noMsgBox
		},
		data() {
			return {
				shareList: [],
				isLoading:true,
			};
		},
		onLoad() {
			this.getPageList()
		},
		methods: {
			getPageList() {
				queryMyShareList().then(res => {
					if (res.code == '00000000') {
						this.shareList = res.data
						this.isLoading = false
					}else{
						this.isLoading = false
					}
				})
			},
			jumpPage(item) {
				if(item.isDelete){ // 已下架的
					return
				}
				if (item.businessType == 1) {
					uni.navigateTo({
						url: `/pages/product/productDetail?id=${item.businessId}`
					})
				} else if (item.businessType == 2) {
					uni.navigateTo({
						url: `/pages/scheme/schemeDetail?id=${item.businessId}&name=${item.typeName}`
					})
				}
			},
		}
	}
</script>

<style lang="scss">
	.container {
		height: 100vh;
		background-color: #FAFAFA;
		padding: 30rpx;

		.shareItemBox {
			margin-bottom: 20rpx;
			background-color: #fff;
			border-radius: 12rpx;
			padding: 30rpx;
			box-shadow: 0px 0px 2rpx 0px rgba(0, 0, 0, 0.2);

			.topBox {
				line-height: 32rpx;
				padding-bottom: 20rpx;
				border-bottom: 1rpx solid #F5F5F5;

				&>view {
					display: flex;

					.titleBox {
						font-size: 32rpx;
						font-weight: 700;
						display: block;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						height: 40rpx;
						max-width: 80%;
						color: #3B384B;
					}

					.productNameBox {
						color: #00BF5B;
						font-size: 20rpx;
						padding: 4rpx 10rpx;
						border-radius: 20rpx;
						background-color: rgb(240, 251, 245);
						margin-left: 14rpx;
						vertical-align: top;
					}
				}

				&>text {
					color: #9C9C9C;
					font-size: 24rpx;
					display: block;
					margin-top: 8rpx;
				}
			}
		}
		.deleteItem{
			background-color: #e4e3e3;
			position: relative;
			.deleteTxt{
				right: 30rpx;
				width: 100rpx;
				position: absolute;
				top: 40rpx;
				color: #e40b00;
				transform: rotate(30deg);
			}
		}
		.msgBox {
			display: flex;
			justify-content: space-between;
			margin-top: 30rpx;

			&>view {
				width: 48%;

				&>text {
					color: #00BF5B;
					font-size: 40rpx;
				}

				&>view {
					font-size: 28rpx;
					margin-top: 10rpx;
				}
			}

			&>view:first-child {
				border-right: 1rpx solid #F5F5F5;
				margin-right: 3%;
			}
		}

	}
</style>
